<template>
  <div class="side">
    <div style="width:50%;margin-top:20px;">
      <el-form :model="SidebarSet" label-position="right" label-width="220px" ref="dataForm">
        <el-form-item label="侧边栏功能">
          <el-radio-group v-model="SidebarSet.status">
            <el-radio label="1">开启</el-radio>
            <el-radio label="0">关闭</el-radio>
          </el-radio-group>
          <p style="font-size:14px;color:#606266;margin:0;">网校开启侧边栏后，客服的悬浮框会失效</p>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="createData()">提交</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
  import {addSidebarSetData, getSidebarSetData} from '@/api/system/side';
  import {getTenantId} from '@/utils/auth';

  export default {
    data() {
      return {
        SidebarSet: {
          status: '',
        }
      }
    },
    created() {
      this.fetchData()
    },
    methods: {
      fetchData() {
        getSidebarSetData(getTenantId()).then(response => {
          this.SidebarSet = response.data
        }).catch(err => {
          console.log(err)
        })
      },
      createData() {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            this.SidebarSet.tenantId = getTenantId();
            addSidebarSetData(this.SidebarSet).then(() => {
              this.$notify({
                title: '成功',
                message: '创建成功',
                type: 'success',
                duration: 2000
              });
              this.fetchData();
            })
          }
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
.side {
}
</style>
